<template>
  <view class="container">
    <!-- 基本信息 -->
    <view class="cd-title">
      <uni-row>
        <uni-col :span="20">
          <view class="param">周报信息</view>
        </uni-col>
      </uni-row>
    </view>
    <!-- 特殊参数 -->
    <view class="cd-body">
      <view class="param">
        <b>周报时间：</b>
        {{titleName}}
      </view>
      <view class="param">
        <b>周报内容：</b>
        {{ msg }}
      </view>
    </view>
    <view class="cd-body">
      <button @click="delreeTask()" type="warn">删除</button>
    </view>
  </view>
</template>
  
  <script>
import { websock } from "../../net/websock";
import { getReport, delReport } from "../../net/weeklyWork";

export default {
  data() {
    return {
      ids: "",
      msg: "",
      titleName: ""
    };
  },
  async onLoad(e) {
    console.log(e.id);
    this.ids = e.id;
    this.getReports(e.id);
  },
  methods: {
    async getReports(e) {
      const id = e;
      const res = await getReport(id);
      if (res.code == 0) {
        this.msg = res.data.content;
        this.titleName = res.data.timeName;
      }
      console.log(res);
    },
    async delreeTask() {
      const id = this.ids;
      const res = await delReport(id);
      if (res.code == 0) {
        let pages = getCurrentPages(); // 当前页面
        const prevPage = pages[pages.length - 2]; //上一页页面实例
        //把数据返回给上一个页面
        console.log(111);
        setTimeout(
          () =>
            uni.navigateBack({
              delta: 1,
              success: function() {
                prevPage.$vm.getNewestTasksWeiwancheng(); // 执行前一个页面的刷新
              }
            }),
          1000
        );
      }
    }
  }
};
</script>
  
  <style>
@import url("../common/detail.css");
</style>
  